<template>
  <v-form
    label-width="140"
    ref="ruleForm"
    :fields="fields"
    :fieldsData="ruleForm"
  >
  </v-form>
</template>
<script>
import formMinxin from "_c/forms/minxins/formMinxin.js";
import { getCommonOptions } from '@/api/common'

export default {
  mixins: [formMinxin],
  props: {
    patchData: Object,
  },
  data() {
    return {
      ruleForm: {
        id: '',
        year: '',
        fundType: '',
        budgetAmount: '',
        remark: '',      
      },
      typeList: [],
    };
  },
  created() {
    getCommonOptions('YWLX').then(res => {
      this.typeList = res.data.map(d => ({ value: d.dmcode, label: d.dmname }))
    });
    this.initForm(this.patchData);
  },
  watch: {
    patchData: function () {
      this.initForm(this.patchData);
    },
  },
  computed: {
    fields: function(){
      return [
        {
          label: "自然年：",
          placeholder: "请选择自然年",
          prop: "year",
          type: "date",
          dType: "year",
          rule: [
            {
              required: true,
              message: "请选择自然年",
              trigger: "blur",
            },
          ],
        },
        {
          label: "基金类型：",
          placeholder: "请选择基金类型",
          prop: "fundType",
          type: "select",
          rule: [
            {
              required: true,
              message: "请选择基金类型",
              trigger: "blur",
            },
          ],
          options: this.typeList,
        },    
        {
          label: "预算金额：",
          placeholder: "请输入预算金额",
          prop: "budgetAmount",
          type: "inputNumber",
          step: 10000,
          max: 1000000000,
          rule: [
            {
              required: true,
              message: "请输入预算金额",
              trigger: "blur",
            },
          ],
        },
        {
          label: "备注：",
          placeholder: "请输入备注",
          prop: "remark",
          type: "textarea",
        },
      ]
    }
  }
};
</script>
<style lang="scss">
</style>